package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.bussiness.domain.SysBusinessDynamic;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.SysBusinessArtwork;
import com.ruoyi.bussiness.service.ISysBusinessArtworkService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 作品上传Controller
 *
 * @author ruoyi
 * @date 2024-01-23
 */
@RestController
@RequestMapping("/bussiness/artwork")
public class SysBusinessArtworkController extends BaseController
{
    @Autowired
    private ISysBusinessArtworkService sysBusinessArtworkService;

    /**
     * 查询作品上传列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:artwork:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBusinessArtwork sysBusinessArtwork)
    {
        startPage();
        List<SysBusinessArtwork> list = sysBusinessArtworkService.selectSysBusinessArtworkList(sysBusinessArtwork);
        return getDataTable(list);
    }

    /**
     * 导出作品上传列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:artwork:export')")
    @Log(title = "作品上传", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBusinessArtwork sysBusinessArtwork)
    {
        List<SysBusinessArtwork> list = sysBusinessArtworkService.selectSysBusinessArtworkList(sysBusinessArtwork);
        ExcelUtil<SysBusinessArtwork> util = new ExcelUtil<SysBusinessArtwork>(SysBusinessArtwork.class);
        util.exportExcel(response, list, "作品上传数据");
    }

    /**
     * 获取作品上传详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:artwork:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysBusinessArtworkService.selectSysBusinessArtworkById(id));
    }

    /**
     * 新增作品上传
     */
    @PreAuthorize("@ss.hasPermi('bussiness:artwork:add')")
    @Log(title = "作品上传", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBusinessArtwork sysBusinessArtwork)
    {
        return toAjax(sysBusinessArtworkService.insertSysBusinessArtwork(sysBusinessArtwork));
    }

    /**
     * 修改作品上传
     */
    @PreAuthorize("@ss.hasPermi('bussiness:artwork:edit')")
    @Log(title = "作品上传", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBusinessArtwork sysBusinessArtwork)
    {
        return toAjax(sysBusinessArtworkService.updateSysBusinessArtwork(sysBusinessArtwork));
    }

    /**
     * 删除作品上传
     */
    @PreAuthorize("@ss.hasPermi('bussiness:artwork:remove')")
    @Log(title = "作品上传", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysBusinessArtworkService.deleteSysBusinessArtworkByIds(ids));
    }


    @PutMapping("/moveUpOrDown")
    public AjaxResult moveUpOrDown(@RequestBody SysBusinessArtwork entity)
    {
        return sysBusinessArtworkService.moveUpOrDown(entity);
    }

}
